const { fstat } = require('fs');
const http = require('http')
const path = require('path')

const readStaticFile = require('./readFileStatic')

http.createServer((req, res) => {
    let urlString = req.url
    //    表示当前物理相对路径   join是把路径进行拼接起来
    let filePathName = path.join(__dirname, './public', urlString)

    let { data, mimeType } = readStaticFile(filePathName, res)

    console.log(data);

    res.write('hello')
    res.end()
}).listen(8080, () => {
    console.log('localhost:8080');
})
